/**
 * 手写一个方法实现以下效果的转码
 * 输入:s="3[ab2[e]]"
 * 输出：abeeabeeabee
 */
var decodeString = function(s) {
 const stack = [];
 let currentStr = '';
 let currentNum = 0;
 for (const char of s) {
     if (!isNaN(char)) {
         currentNum = currentNum * 10 + parseInt(char);// 处理数字（可能是多位数，如"123"需要拼接为123）
     } else if (char === '[') {
         stack.push([currentStr, currentNum]);
         currentStr = ''; 
         currentNum = 0;  
     } else if (char === ']') {
         const [prevStr, num] = stack.pop();
         currentStr = prevStr + currentStr.repeat(num);
     } else {
         currentStr += char;
     }
 }

 return currentStr; 
};
const s = "3[ab2[e]]";
console.log(decodeString(s));